package tests;

import static helper.Util.*;
import static rayCaster.ApplicationInterface.*;
import rayCaster.Pixel;

public class TestUtil {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int width = WIDTH;		
		int height = HEIGHT;
		int half_width = width/2;
		
		Pixel[] pixelsArray = new Pixel[width*height];
		
		//Build manually an image. This puts 3 vertical bands on the image
		//From left to right: REG, GREEN, BLUE
		//The color bands should overlap, it gives a gradient effect !!
		int i=0;
		for  (int y = 0; y < height; y++) {
			for ( int x = 0; x < width; x++) {
		        // Start red on left and decrease to zero at center
		        int red = 255 -  (512 * x)/width;
		        if (red < 0 ) 
		        	red = 0;
	
		        // Green peaks in center
		        int green = 0;
		        if (x < half_width )
		            green =  (512 * x)/width;
		        else
		          green = 255 -  (255 *  (x - half_width))/half_width;
	
		        // Blue starts from center and peaks at right side.
		        int blue = 0;
		        if (x > half_width)
		            blue =  (255 *  (x - half_width))/half_width;
	
		        int alpha = 255; // non-transparent
		        pixelsArray[i++] = new Pixel(alpha, red, green, blue);		        		
			}
		}
		
		//lib.saveImage(pixelsArray, LibInterface.WIDTH, LibInterface.HEIGHT, LibInterface.OUT_FILE, "png");
		//lib.saveImage(pixelsArray, LibInterface.WIDTH, LibInterface.HEIGHT, LibInterface.OUT_FILE, "png");
		//lib.saveImage(pixelsArray, LibInterface.WIDTH, LibInterface.HEIGHT, LibInterface.OUT_FILE, "xang");
		saveImage(pixelsArray, WIDTH, HEIGHT, "pingpong", "png");
		System.out.println("OK");
	}

}
